﻿Imports System.Drawing
Namespace Figuras

    Public Class Circulo
        Inherits Figura

        Sub New()
        End Sub

        Sub New(ByVal radio As Integer)
            Me.Radio = radio
        End Sub

        Private _radio As Integer
        Public Property Radio() As Integer
            Get
                Return _radio
            End Get
            Set(ByVal value As Integer)
                If value <= 0 Then Throw New ArgumentOutOfRangeException("Radio", "El radio debe ser positivo")
                _radio = value
            End Set
        End Property

        Public Overrides Function CalcularArea() As Double
            Return Math.PI * Me.Radio * Me.Radio
        End Function

        Public Overrides Function ContienePunto(ByVal punto As System.Drawing.Point) As Boolean
            Dim distancia As Double
            Dim catetoX As Double = Math.Pow(punto.X - Me.Posicion.X, 2)
            Dim catetoY As Double = Math.Pow(punto.Y - Me.Posicion.Y, 2)
            distancia = Math.Sqrt(catetoX + catetoY)
            Return distancia <= Me.Radio
        End Function

        Public Overrides Sub Dibujar(ByVal lienzo As System.Drawing.Graphics)
            Dim rectangle As New Rectangle(Me.Posicion, New Size(Me.Radio * 2, Me.Radio * 2))
            lienzo.FillEllipse(Brushes.Blue, rectangle)
            lienzo.DrawEllipse(Drawing.Pens.Black, rectangle)
        End Sub
    End Class

End Namespace